module NWD::ControllerMethods
  require 'ninja_web_debugger'

  def self.included(base)
    base.class_eval do
      around_filter :ninja_debugger_filter
    end
  end

  def ninja_debugger_filter
    # Skip the 'ajax_minja_debugger' action
    unless self.controller_name == 'ninja_web_debugger'
      logger.debug "ninja debugging around your action"
      @log_key = get_log_key
      @request_id = NinjaWebDebugger.before(@log_key, session, request)
    end

    yield

    unless self.controller_name == 'ninja_web_debugger'
      NinjaWebDebugger.after(@log_key, @request_id)
    end
  end

  private
  def get_log_key
    "#{request.request_uri}".to_sym
  end
  
end